﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Web.PageUI
{
    /// <summary>
    /// 前端通用详细页方法
    /// </summary>
    public class BaseDetail : Base
    {
        public dynamic curModel = new Evan.Model.DynamicModel();
        public dynamic prveModel = new Evan.Model.DynamicModel();
        public dynamic nextModel = new Evan.Model.DynamicModel();
        public string SeoTitle = "";
        public string SeoKeywords = "";
        public string SeoDescription = "";
        public Evan.DataBase.DbOperat BLL_Module = new Evan.DataBase.DbOperat("Module");
        public BaseDetail()
        {
            if (curId > 0)
            {
                curModel = curBLL.GetModel_1("Id=@Id and States=1", curId);
            }
            else if (!string.IsNullOrEmpty(curGUID))
            {
                curModel = curBLL.GetModel_1("Guids=@Guids and States=1", curGUID);
            }
            #region 定时发布的内容处理 , 如果没有发布重置对象null , 触发空指针异常 , 页面指向404
            if (curModel != null)
            {
                if (new Evan.BLL.Base().GetHasReleaseTime(curTable))
                {
                    DateTime rt = Convert.ToDateTime(curModel.ReleaseTime);
                    if (DateTime.Now < rt)
                    {
                        curModel = null;
                    }
                }
            }
            #endregion

            SeoTitle = curModel.SeoTitle;
            SeoKeywords = curModel.SeoKeyWords;
            SeoDescription = curModel.SeoDescription;

            prveModel = GetPrveModel(curModel);
            nextModel = GetNextModel(curModel);
        }
    }
}
